package com.smart.wap.app;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.smart.common.entities.ajax.AjaxResult;
import com.smart.common.entities.constant.SmartConstant;
import com.smart.service.socket.WebSocket;
import com.smart.utils.MemberStp;
import com.smart.wap.service.OpenService;
import com.smart.wap.service.WorkStaffService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "WTB-移动端-公共类")
@RestController
@RequestMapping(SmartConstant.WAP_API_PREFIX + "app/open")
@RequiredArgsConstructor
@Log4j2
public class OpenController {

    private final OpenService openService;


    private final WebSocket webSocket;

    @ApiOperation(value = "获取随机5个公共摄像头(直播)")
    @GetMapping(value = "getOpenCamera/{kind}")
    @ApiOperationSupport(order = 1)
//    @SaCheckLogin(type = MemberStp.TYPE)
    public AjaxResult<List<String>> getOpenCamera(@PathVariable String kind) {
        List<String> camera = openService.getOpenCamera(kind);
        return AjaxResult.data(camera);
    }


    @ApiOperation(value = "获取所有加工厂摄像头(直播)")
    @GetMapping(value = "getOpenProcessingCamera")
    @ApiOperationSupport(order = 1)
    @SaCheckLogin(type = MemberStp.TYPE)
    public AjaxResult<List<String>> getOpenProcessingCamera() {
        List<String> camera = openService.getOpenProcessingCamera();
        return AjaxResult.data(camera);
    }


    @ApiOperation(value = "获取随机5个圈养摄像头(Html播放)")
    @GetMapping(value = "getOpenCameraHtml")
    @ApiOperationSupport(order = 1)
//    @SaCheckLogin(type = MemberStp.TYPE)
    public AjaxResult<List<String>> getOpenCameraHtml() {
        List<String> camera = openService.getOpenCameraHtml();
        return AjaxResult.data(camera);
    }

    @ApiOperation(value = "获取随机5个散养摄像头(Html播放)")
    @GetMapping(value = "getOpenSanCameraHtml")
    @ApiOperationSupport(order = 1)
//    @SaCheckLogin(type = MemberStp.TYPE)
    public AjaxResult<List<String>> getOpenSanCameraHtml() {
        List<String> camera = openService.getOpenSanCameraLive();
        return AjaxResult.data(camera);
    }

    @ApiOperation(value = "获取随机5个摄像头(ezopen协议)")
    @GetMapping(value = "getOpenCameraLive")
    @ApiOperationSupport(order = 1)
//    @SaCheckLogin(type = MemberStp.TYPE)
    public AjaxResult<List<String>> getOpenCameraLive() {
        List<String> camera = openService.getOpenCameraLive();
        return AjaxResult.data(camera);
    }


    @ApiOperation(value = "webScoKet测试")
    @GetMapping(value = "webScoKet/{id}/{msg}")
    public AjaxResult<String> addWebScoKet(@PathVariable Long id, @PathVariable String msg) {

        String message = webSocket.sendOneMessage(id, msg);

        return AjaxResult.success(message);
    }

    private final WorkStaffService workStaffService;

//     @ApiOperation(value = "cscs")
//    @GetMapping(value = "cs/{code}")
//    public AjaxResult<String> addWebScoKet(@PathVariable String code) {
//
//         workStaffService.getTheReplay(code,"20231225121500","20231226002000");
//
//        return AjaxResult.success();
//    }





}
